require "erb";

class PHPController
  attr_accessor :attributes, :model_name, :table_name;
  
  def initialize(opts)
    opts.each do |var, value|
      instance_variable_set("@#{var}", value);
    end
  end
  
  def make_code
    code = File.open("tests/php_create/controller.php.erb"){|f| f.read;};
    code = ERB.new(code);
    code.run(binding);
  end
    
end

php_controller = PHPController.new(
  :controller_name => "Posts",
  :model_name => "Post",
  :record_name => "post",
  :plural => "posts",
  :output => {
    :plural => "Noticias",
    :sing => "Noticia"
  },
  :layout => "public",
  :attributes => {
    :title => "text",
    :body => "text"
  }
);

print php_controller.make_code;